package com.medical.admin.cost.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.medical.admin.cost.common.dto.DetailInfo;
import com.medical.admin.cost.common.dto.OutpatientInfo;
import com.medical.admin.cost.common.dto.OutpatientRechargeInfo;
import com.medical.admin.cost.common.dto.RechargeDto;
import com.medical.admin.cost.service.RechargeService;
import com.qf.medical.response.ResponseEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * 1.分页查询充值记录
 * 2.添加充值信息
 * 3.删除充值信息
 * 4.修改充值信息
 * 5.查询充值详细信息
 * 6.门诊充值详情
 */
@Api(tags = "后台充值记录管理Api在线文档")
@RestController
@RequestMapping("/recharge")
public class OutpatientRechargeController {
    @Resource
    private RechargeService rechargeService;

    @ApiOperation("动态分页查询充值记录")
    @PostMapping("/searchList/{page}/{size}")
    @ApiImplicitParams({@ApiImplicitParam(name = "outpatientRechargeInfo",value = "dto参数实体类"),
            @ApiImplicitParam(name = "page",value = "页码"),@ApiImplicitParam(name = "size",value = "条数")})
    public ResponseEntity<IPage<OutpatientRechargeInfo>> searchList(@NotNull @RequestBody OutpatientRechargeInfo outpatientRechargeInfo,
                                                            @RequestParam(name = "page",defaultValue = "1")@PathVariable("page") Integer page,
                                                            @RequestParam(name = "size",defaultValue = "10") @PathVariable("size") Integer size){
        return ResponseEntity.success(rechargeService.searchList(outpatientRechargeInfo,page,size));
    }

    @ApiOperation("充值信息添加")
    @PostMapping("/addRecharge")
    @ApiImplicitParam(name = "rechargeDto",value = "充值dto类")
    public ResponseEntity<Integer> addRecharge(@NotNull @RequestBody RechargeDto rechargeDto){
        return ResponseEntity.success(rechargeService.addRecharge(rechargeDto));
    }

    @ApiOperation("充值信息删除")
    @DeleteMapping("/removeRecharge")
    @ApiImplicitParam(name = "rechargeId",value = "充值id")
    public ResponseEntity<Integer> removeRecharge(@NotNull Integer rechargeId ){
        return ResponseEntity.success(rechargeService.removeRecharge(rechargeId));
    }

    @ApiOperation("充值修改信息")
    @PutMapping("/modifyRecharge")
    @ApiImplicitParam(name = "rechargeDto",value = "充值dto类")
    public ResponseEntity<Integer> modifyRecharge(@NotNull @RequestBody RechargeDto rechargeDto){
        return ResponseEntity.success(rechargeService.modifyRecharge(rechargeDto));
    }

    @ApiOperation("查询充值详细信息")
    @GetMapping("/detailRecharge")
    @ApiImplicitParam(name = "rechargeId",value = "充值id")
    public ResponseEntity<RechargeDto> detailRecharge(@NotNull  Integer rechargeId){
        return ResponseEntity.success(rechargeService.detailRecharge(rechargeId));
    }

    @ApiOperation("门诊充值详情")
    @GetMapping("/outpatient/detailRecharges")
    @ApiImplicitParam(name = "patientId",value = "患者id")
    public ResponseEntity<DetailInfo> detailRecharges(@NotNull  Long patientId){
        return ResponseEntity.success(rechargeService.outpatientDetailRecharges(patientId));
    }
}
